﻿#If WINDOWS_PHONE Then

Namespace Global.System.Collections.Concurrent

    Public Class ConcurrentQueue(Of T)
        Inherits Queue(Of T)

        Private m_instanceLock As New Object()

        Public Function TryDequeue(ByRef item As T) As Boolean
            Try
                SyncLock Me.m_instanceLock
                    item = MyBase.Dequeue()
                    Return True
                End SyncLock
            Catch ex As Exception
                Return False
            End Try
        End Function

        Public Function TryPeek(ByRef item As T) As Boolean
            Try
                SyncLock Me.m_instanceLock
                    item = MyBase.Peek()
                    Return True
                End SyncLock
            Catch ex As Exception
                Return False
            End Try
        End Function

    End Class

End Namespace

#End If